package com.example.cardgame

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class EditInfoActivity : AppCompatActivity() {
    private lateinit var editName: EditText
    private lateinit var editGender: EditText
    private lateinit var editPhone: EditText
    private lateinit var saveButton: Button

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_edit_info)

        editName = findViewById(R.id.editName)
        editGender = findViewById(R.id.editGender)
        editPhone = findViewById(R.id.editPhone)
        saveButton = findViewById(R.id.saveButton)

        saveButton.setOnClickListener {
            // 保存信息
            val newName = editName.text.toString()
            val newGender = editGender.text.toString()
            val newPhone = editPhone.text.toString()

            // 将信息传回到MainActivity
            val resultIntent = Intent()
            resultIntent.putExtra("name", newName)
            resultIntent.putExtra("gender", newGender)
            resultIntent.putExtra("phone", newPhone)
            setResult(Activity.RESULT_OK, resultIntent)
            finish()
        }
    }
}